<?php
include("template_top.php");
?>
<h1>Desktop Support Technician Center</h1>
<p>
<table width="100%">
<?php
$count = 4;
$sql = "SELECT * FROM `tbTechs` ORDER BY `sTech` ASC";
$q = db::Query($sql);
while($row = $q->fetch()){
if($count == 4){
echo "<tr>";
$count = 1;
}
?>
<td>
<?php
if($row['sExtension'] == ""){
	$row['sExtension'] = "N/A";
}
if($row['sNextel'] == ""){
	$row['sNextel'] = "N/A";
}
if($row['sEmail'] == ""){
	$row['sEmail'] = "N/A";
}
if((time() - $row['sLastCall']) > 899){
	$sStatus = '<font color="green">Avaliable For Call</font>';
}else{
	$sStatus = '<font color="red">Out On A Call - '.date("g:i A", $row['sLastCall']).'</font>';
}
if($row['sHours'.date("D")] == ""){
	$sStatus = '<font color="red">Off Shift</font>';
}else{
	$temp = explode("-", $row['sHours'.date("D")]);
	$sStart = $temp[0];
	$sEnd = $temp[1];
	$sStart = strtotime($sStart.":00 ".date("M j, Y"));
	$sEnd = strtotime($sEnd.":00 ".date("M j, Y"));
	if($sStart < time()){
		if($sEnd < time()){
			$sStatus = '<font color="red">Off Shift</font>';
		}
	}else{
		$sStatus = '<font color="red">Off Shift</font>';
	}
}
if($row['sOutTill'] != ""){
	if(time() < $row['sOutTill']){
		$sStatus = '<font color="red">Tech Called Out</font>';
	}
}
if($row['sProjectTill'] != ""){
	if(time() < $row['sProjectTill']){
		$sStatus = '<font color="red">Working On Project</font>';
	}
}
?>
<b><?php echo $row['sTech'] ?></b><br/>
&nbsp;&nbsp;&nbsp;<b>Status:</b> <?php echo $sStatus ?><br/>
<?php if($sStatus == '<font color="red">Working On Project</font>'){ ?>
&nbsp;&nbsp;&nbsp;<b>Project End Time:</b>
<?php
if(date("n/j/Y", $row['sProjectTill']) == date("n/j/Y")){
	echo "Today @ ".date("g:i A", $row['sProjectTill']);
}elseif(date("n/j/Y", $row['sProjectTill']) == date("n/j/Y", strtotime("tomorrow"))){
	echo "Tomorrow @ ".date("n/j/Y @ g:i A", $row['sProjectTill']);
}else{
	echo date("n/j/Y @ g:i A", $row['sProjectTill']);
}
?><br/>
<?php } ?>
<?php if($row['sHours'.date("D")] != ""){ ?>
<?php if(time() < $row['sOutTill']){ ?>
&nbsp;&nbsp;&nbsp;<b>Today's Hours:</b> Called Out<br/>
<?php }else{ ?>
&nbsp;&nbsp;&nbsp;<b>Today's Hours:</b> <?php echo date("g A", $sStart)." - ".date("g A", $sEnd); ?><br/>
<?php } ?>
<?php }else{ ?>
&nbsp;&nbsp;&nbsp;<b>Today's Hours:</b> Off Today<br/>
<?php } ?>
&nbsp;&nbsp;&nbsp;<b>Extension:</b> <?php echo $row['sExtension'] ?><br/>
&nbsp;&nbsp;&nbsp;<b>Nextel:</b> <?php echo $row['sNextel'] ?><br/>
&nbsp;&nbsp;&nbsp;<b>E-Mail:</b> <?php echo $row['sEmail'] ?><br/><br/>
</td>
<?php 
$count ++;
if($count ==4){
echo "</tr>";
}
}
?>
</table>
<?php
include("template_bot.php");
?>